home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / regist / register.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-03-06  |  6.0 KB  |  169 lines

  1. VERSION 2.00
  2. Begin Form frmRegister 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Registration Information"
  5.    ClientHeight    =   3705
  6.    ClientLeft      =   1230
  7.    ClientTop       =   2730
  8.    ClientWidth     =   5775
  9.    Height          =   4050
  10.    Left            =   1200
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   3705
  13.    ScaleWidth      =   5775
  14.    Top             =   2415
  15.    Width           =   5835
  16.    Begin TextBox Text5 
  17.       Height          =   285
  18.       Left            =   90
  19.       TabIndex        =   10
  20.       Top             =   3330
  21.       Width           =   5595
  22.    End
  23.    Begin TextBox Text4 
  24.       Height          =   285
  25.       Left            =   90
  26.       TabIndex        =   8
  27.       Top             =   2700
  28.       Width           =   5595
  29.    End
  30.    Begin TextBox Text3 
  31.       Height          =   285
  32.       Left            =   90
  33.       TabIndex        =   6
  34.       Top             =   2070
  35.       Width           =   5595
  36.    End
  37.    Begin TextBox Text2 
  38.       Height          =   285
  39.       Left            =   90
  40.       TabIndex        =   4
  41.       Top             =   1440
  42.       Width           =   5595
  43.    End
  44.    Begin TextBox Text1 
  45.       Height          =   285
  46.       Left            =   90
  47.       TabIndex        =   1
  48.       Text            =   "<Target Company> : <Target User>"
  49.       Top             =   360
  50.       Width           =   5595
  51.    End
  52.    Begin CommandButton Command1 
  53.       Caption         =   "&Generate REGISTER.LIC"
  54.       Default         =   -1  'True
  55.       Height          =   375
  56.       Left            =   90
  57.       TabIndex        =   2
  58.       Top             =   720
  59.       Width           =   5595
  60.    End
  61.    Begin Label Label5 
  62.       BackStyle       =   0  'Transparent
  63.       Caption         =   "rgrID readed from REGISTER.LIC"
  64.       Height          =   195
  65.       Left            =   90
  66.       TabIndex        =   9
  67.       Top             =   3060
  68.       Width           =   5595
  69.    End
  70.    Begin Label Label4 
  71.       BackStyle       =   0  'Transparent
  72.       Caption         =   "rgrNAME readed from REGISTER.LIC"
  73.       Height          =   195
  74.       Left            =   90
  75.       TabIndex        =   7
  76.       Top             =   2430
  77.       Width           =   5595
  78.    End
  79.    Begin Label Label3 
  80.       BackStyle       =   0  'Transparent
  81.       Caption         =   "CRC32 for REGISTER.LIC is"
  82.       Height          =   195
  83.       Left            =   90
  84.       TabIndex        =   5
  85.       Top             =   1800
  86.       Width           =   5595
  87.    End
  88.    Begin Label Label2 
  89.       BackStyle       =   0  'Transparent
  90.       Caption         =   "Registration &ID (rgrID) is"
  91.       Height          =   195
  92.       Left            =   90
  93.       TabIndex        =   3
  94.       Top             =   1170
  95.       Width           =   5595
  96.    End
  97.    Begin Label Label1 
  98.       BackStyle       =   0  'Transparent
  99.       Caption         =   "&Enter name (rgrNAME) for registration"
  100.       Height          =   195
  101.       Left            =   90
  102.       TabIndex        =   0
  103.       Top             =   90
  104.       Width           =   5595
  105.    End
  106. Option Explicit
  107. Sub Command1_Click ()
  108.    Dim rgrNAME    As String
  109.    Dim rgrID      As String
  110.    Dim readNAME   As String
  111.    Dim readID     As String
  112.    Dim CRC        As Long
  113.    ' read the registration name
  114.    rgrNAME = Trim$(text1.Text)
  115.    ' check if the registration name exist
  116.    If (Len(rgrNAME) = 0) Then
  117.       ' no, display an error message
  118.       MsgBox "Enter a name for registration", , Me.Caption
  119.       ' bye
  120.       Exit Sub
  121.    End If
  122.    ' disable the button
  123.    Command1.Enabled = False
  124.    ' *** replace <Your Password> with your own password (the password can be any char (chr$(1)->chr$(254))
  125.    ' *** you can change the encrypt level
  126.    rgrID = cToHexa(cEncrypt(rgrNAME, "<Your Password>", ENCRYPT_LEVEL_0))
  127.    ' create the .LIC from the basis license file
  128.    FileCopy "c:\register\register.cil", "c:\register\register.lic"
  129.    ' open the .LIC file in append mode to add registration information
  130.    Close #1
  131.    Open "c:\register\register.lic" For Append Shared As #1
  132.    ' add a CTRL+Z for using with cFileCRC32 in TEXT mode
  133.    Print #1, Chr$(26)
  134.    ' add a section header to use with cGetIni (* replace <Your Section> with your own section *)
  135.    Print #1, "[<Your Section>]"
  136.    ' add the the NAME of registration
  137.    Print #1, "rgrNAME = "; rgrNAME
  138.    ' add the the ID of registration
  139.    Print #1, "rgrID = "; rgrID
  140.    ' close the .LIC file
  141.    Close #1
  142.    ' display the ID
  143.    Text2.Text = rgrID
  144.    ' display the CRC32, file must be open in TEXT mode (read until CTRL+Z is encountered),
  145.    ' you can save this CRC32 in your file on a LONG integer,
  146.    ' compare the CRC32 calculated and the CRC32 in you file to see,
  147.    '  if a modification has been made.
  148.    CRC = cFileCRC32("c:\register\register.lic", OPEN_MODE_TEXT)
  149.    Text3.Text = CRC
  150.    ' read the rgrNAME (* replace <Your Section> with your own section *)
  151.    readNAME = cGetINI("<Your Section>", "rgrNAME", "?", "c:\register\register.lic")
  152.    Text4.Text = readNAME
  153.    ' read the rgrID (* replace <Your Section> with your own section *)
  154.    readID = cGetINI("<Your Section>", "rgrID", "?", "c:\register\register.lic")
  155.    Text5.Text = readID
  156.    ' check if the ID is correct and is the CRC32 is correct
  157.    ' *** replace <Your Password> with your own password
  158.    ' *** you can change the encrypt level in accordance with above
  159.    If ((CRC = cFileCRC32("c:\register\register.lic", OPEN_MODE_TEXT)) And (readID = cToHexa(cEncrypt(rgrNAME, "<Your Password>", ENCRYPT_LEVEL_0)))) Then
  160.       ' display validity message
  161.       MsgBox "Registration ID is valid" & Chr$(13) & Chr$(13) & "REGISTERED INFO : " & readNAME, , Me.Caption
  162.    Else
  163.       ' display non-validity message
  164.       MsgBox "Your license file is invalid." & Chr$(13) & Chr$(13) & "Program will be stopped.", , Me.Caption
  165.    End If
  166.    ' enable the button
  167.    Command1.Enabled = True
  168. End Sub
  169.